#pragma once
#ifndef SEM_PV_H
#define SEM_PV_H
#include<thread>
#include<condition_variable>
#include<iostream>
#include<atomic>

using namespace std;


#define MagicNum 11

class Sem_Pv
{
public:
    Sem_Pv();
    Sem_Pv(int val);
    ~Sem_Pv();
    void set_CanUse();
    void sem_P();
    void sem_Try_P();
    void sem_V();
    bool sem_Try_V();
    void set_Val(int val);
private:
    int magic;
    atomic<int> waiting_num;
    atomic<int> free_qua;
    mutex mu;
    condition_variable con;
};

#endif // SEM_PV_H
